
#include "ros/ros.h"
#include "cre/CreServiceMsgRequest.h"
#include "cre/CreServiceMsgResponse.h"
#include "cre/CreServiceMsg.h"

bool myServiceCallback(cre::CreServiceMsgRequest &req, cre::CreServiceMsgResponse &res) {
    // 处理服务请求
    res.output = req.input * 2;
    ROS_INFO("Request: input = %d, output = %d", req.input, res.output);
    return true;
}

int main(int argc, char **argv) {
    // 初始化ROS节点
    ros::init(argc, argv, "cre_service_node");
    // 创建节点句柄
    ros::NodeHandle nh;
    // 创建服务
    ros::ServiceServer service = nh.advertiseService("cre_service", myServiceCallback);
    ROS_INFO("Ready to receive service requests.");

    // 循环处理ROS回调函数
    ros::spin();
    return 0;
}